{% if groups.virthost is defined and hostvars[groups['virthost'][0]].ansible_host is defined %}

Host virthost
    Hostname {{ hostvars[groups['virthost'][0]].ansible_host }}
{% if hostvars[groups['virthost'][0]].ansible_private_key_file is defined %}
    IdentityFile {{ hostvars[groups['virthost'][0]].ansible_private_key_file }}
{% endif %}
    User {{ ssh_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% else %}

Host virthost
    Hostname {{ hostvars['localhost'].ansible_default_ipv4.address }}
{% if id_rsa_virt_power_exists is defined %}
    IdentityFile {{ local_working_dir }}/id_rsa_virt_power
{% endif %}
    User {{ ssh_user }}
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null

{% endif %}
